home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / doc / gpc / docdemos / bindingdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-02-09  |  987 b   |  42 lines

  1. program BindingDemo (Input, Output, f);
  2.  
  3. var
  4.   f : bindable Text;
  5.   b : BindingType;
  6.  
  7. procedure BindFile (var f : Text);
  8. var
  9.   b : BindingType;
  10. begin
  11.   Unbind (f);
  12.   b := Binding (f);
  13.   repeat
  14.     Write ('Enter a file name: ');
  15.     ReadLn (b.Name);
  16.     Bind (f, b);
  17.     b := Binding (f);
  18.     if not b.Bound then
  19.       WriteLn ('File not bound -- try again.')
  20.   until b.Bound
  21. end;
  22.  
  23. begin
  24.   BindFile (f);
  25.   { Now the file f is bound to an external file. We can use the
  26.     implementation defined fields of BindingType to check if the
  27.     file exists and is readable, writable or executable. }
  28.   b := Binding (f);
  29.   Write ('The file ');
  30.   if b.Existing then
  31.     WriteLn ('exists.')
  32.   else
  33.     WriteLn ('does not exist.');
  34.   Write ('It is ');
  35.   if not b.Readable then Write ('not ');
  36.   Write ('readable, ');
  37.   if not b.Writable then Write ('not ');
  38.   Write ('writable and ');
  39.   if not b.Executable then Write ('not ');
  40.   WriteLn ('executable.')
  41. end.
  42.